﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Xml;

namespace Client
{
    public partial class DangNhap : Form
    {
        public delegate void RegisterHandler(Form frm);
        public event RegisterHandler RegisterEvent;
        public delegate void LoginHandler(Form frm, string user, string pass);
        public event LoginHandler LoginEvent;
        public delegate void DongFormHandler();
        public event DongFormHandler DongFormEvent;
        public DangNhap()
        {
            InitializeComponent();
        }
        private void btnclose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if(DongFormEvent != null)
            {
                DongFormEvent();
            }
        }

       
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (LoginEvent != null)
            {
                LoginEvent(this ,txtacc.Text, txtpass.Text);
            }
            //string ttdangnhap = "login|"+txtacc.Text+"|"+txtpass.Text;
            //ttdangnhap = CCryptography.MaHoa(ttdangnhap);
            //send.WriteLine(ttdangnhap);
            //send.Flush();
              
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            CConfig config = new CConfig();
            txtacc.Text = config.Name;
            txtpass.Text = config.Pass;
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (RegisterEvent != null)
            {
                RegisterEvent(this);
            }
        }
    }
}
